package com.xm.servlet.reception_desk.captcha;

import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.xm.util.MailboxUtil;
import lombok.SneakyThrows;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 验证邮箱验证码
 * @author 康文程
 * @date 2023-12-24 下午 02:43
 */
@WebServlet("/verify/mailbox/captcha")
public class VerifyMailboxCaptcha extends HttpServlet {
    private final MailboxUtil mailboxUtil = new MailboxUtil();

    @SneakyThrows(IOException.class)
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
        String mailbox = req.getParameter("mailbox");
        String code = req.getParameter("code");
        try {
            MailboxUtil.mailboxVerificationCode(mailbox, code);
        } catch (TencentCloudSDKException e) {
            resp.getWriter().println("-1");
        }
    }
}
